#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <functional>
#include <boost/bind.hpp>
#include <boost/timer.hpp>
#include <boost/shared_ptr.hpp>

using namespace std;

struct A
{
	virtual void f()=0;
};

struct B:public A
{
       void f()
       {
	       cout<<"I am B"<<endl;
       }
};

struct C:public A
{
       void f()
       {
	       cout<<"I am C"<<endl;
       }

       void g()
       {
	       cout<<"C::g()"<<endl;
       }
};

int main(int argc, char **argv)
{
	A *b = new B;
	A *c = new C;
        //c->g();//error 
	dynamic_cast<C*>(c)->g();
	if(!dynamic_cast<C*>(b))
		cout<<"b is not a C"<<endl;

	b->f();
	c->f();

	cout<<typeid(b).name()<<endl;
	cout<<typeid(c).name()<<endl;
	cout<<typeid(*b).name()<<endl;
	cout<<typeid(*c).name()<<endl;

	if(typeid(b)==typeid(c))
		cout<<"b c is the same type."<<endl;

	if(typeid(*b)!=typeid(*c))
		cout<<"*b *c is not the same type."<<endl;

	return 0;
}
